/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package esimerkit;

import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent;
import javax.swing.JApplet;

/**
 *
 * @author MaPas
 */
public class E4_Nappaimisto extends JApplet {

    @Override
    public void init() {
        KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
        manager.addKeyEventDispatcher(new MyKeyDispatcher());
    }

    class MyKeyDispatcher implements KeyEventDispatcher {

        @Override
        public boolean dispatchKeyEvent(KeyEvent e) {
            if (e.getID() == KeyEvent.KEY_PRESSED) {
                System.out.println("KEY_PRESSED");
            } else if (e.getID() == KeyEvent.KEY_RELEASED) {
                System.out.println("KEY_RELEASED");
            } else if (e.getID() == KeyEvent.KEY_TYPED) {
                System.out.println("KEY_TYPED");
            }
            return false;
        }
    }
}